package com.jy.horny.function.wlm.viewmodel

import com.framework.network.remote.NetworkObserver
import com.framework.network.remote.endRequest
import com.framework.network.remote.error
import com.framework.network.remote.requestObserver
import com.framework.network.remote.startRequest
import com.framework.network.remote.success
import com.jy.horny.base.BaseVMViewModel
import com.jy.horny.base.HttpRequestListener
import com.jy.horny.base.Request
import com.jy.horny.model.PolicyModel

class WhoLikeMeViewModel : BaseVMViewModel() {
    fun test(lisetener: HttpRequestListener<PolicyModel>) {
        request(lisetener,"testHttpRequest", request = object : Request {
            override fun request(map: HashMap<String, Any>, requestEndListener: (() -> Unit?)?) {
                apiService?.postPolicy(map)?.requestObserver(
                    NetworkObserver<PolicyModel>().startRequest {
                        showLoading()
                        lisetener.startRequest(it)
                    }.success {
                        lisetener.success(it)
                    }.error {
                        lisetener.error(it)
                    }.endRequest {
                        lisetener.endRequest()
                        hideLoading()
                        requestEndListener?.invoke()
                    }
                )

            }

        })

    }
}